﻿using System.Web.Mvc;
using Deepcode.ValidationSample.Models;

namespace Deepcode.ValidationSample.Controllers
{
	[HandleError]
	public class AjaxUiFormController : Controller
	{
		[HttpGet]
		public ActionResult Index()
		{
			return View();
		}

		[HttpGet]
		public ActionResult FormFragment()
		{		
			return View(new BookViewModel());
		}

		[HttpPost]
		[ValidateAntiForgeryToken]
		public ActionResult PostFormData(BookViewModel model)
		{
			if( ! ModelState.IsValid )
				return View("FormFragment", model);

			return View("PostedDone");
		}
	}
}
